import cv2
import numpy as np
from enum import Enum


class SlotType(Enum):
    FRAME = 0
    RIGHT_SIDE = 2
    LEFT_SIDE = 1
    INVALID = 3


class Light:
    def __init__(self):
        self.ratio = 0.0  # Rectangle ratio
        self.roi_max_area = 0.0  # Maximum contour area
        self.max_area_contour = None  # Maximum contour area
        self.contour_num = 0  # Number of contours inside ROI
        self.center = (0.0, 0.0)  # Center point of the light
        self.pts = []  # Points of the light
        self.sub_rect = None  # ROI region
        self.opt_rect = None  # Optimized ROI region
        self.index = -1  # Corner index
        self.convex_start = None  # Convex hull start point
        self.convex_end = None  # Convex hull end point
        self.convex_far = None  # The farthest point of the convex hull
        self.opt_pts = []  # Optimized corner points

        self.others_pts1 = None
        self.others_pts2 = None

        self.opt_rect_corners = None


class Slot:
    def __init__(self):
        self.type = SlotType.INVALID  # SlotType enum
        self.confidence = 0.0  # Confidence of the slot
        self.pts = []  # Original corner points
        self.center = (0.0, 0.0)  # Center of the contour
        self.opt_pts = []  # Optimized corner points
        self.lights = []  # List of Light objects
        self.roi = None  # ROI reference (warp_img)
        self.rect = None
        self.opt_rect = None
